package cc.vv.btpartyjob.jnimodule.server

import android.app.Activity
import android.content.Context
import android.content.Intent
import android.text.TextUtils
import cc.vv.baselibrary.util.LKLogUtil
import cc.vv.baselibrary.util.router.RouterActivityIntentResourceKey
import cc.vv.baselibrary.util.router.RouterTransferCenterUtil
import cc.vv.btpartyjob.jnimodule.activity.OrganizationActivity
import cc.vv.btpartyjob.jnimodule.activity.VillageCunActivity
import cc.vv.btpartyjob.jnimodule.enums.H5UrlEnum
import cc.vv.btpartyjob.jnimodule.globle.IntentJniKey

/**
 * 路由跳转activity
 * Created by Chen.qi on 2018/10/24.
 */
object JniStartActivity {

    /**
     * 跳转web页面
     */
    fun startIntentWebActivity(context: Context, urlEnum: H5UrlEnum, id: String?, webTitle: String = "") {
        val title = if (TextUtils.isEmpty(webTitle)) urlEnum.name else webTitle
        val url = urlEnum.value + id
        LKLogUtil.e("H5Url:$url")
        startIntentWebActivity(context, title, url)
    }

    /**
     * 跳转web页面
     */
    fun startIntentWebActivity(context: Context, webTitle: String, webUrl: String?) {
        val webIntent: Intent = RouterTransferCenterUtil.getInstance().getRouterIntent(context,
                RouterActivityIntentResourceKey.KEY_WEB_VIEW_ACTIVITY)
        webIntent.putExtra(IntentJniKey.INTENT_KEY_WEB_TITLE, webTitle)
        webIntent.putExtra(IntentJniKey.INTENT_KEY_WEB_URL, webUrl)
        RouterTransferCenterUtil.getInstance().routerStartActivity(context, webIntent)
    }

    /**
     * 跳转组织架构
     */
    fun startIntentOrganActivity(activity: Activity, type: Int, chooseType: Int, requestCode: Int, allPath: Boolean = false) {
        val intent = Intent(activity, OrganizationActivity::class.java)
        intent.putExtra(IntentJniKey.INTENT_KEY_ORG_TYPE, type)
        intent.putExtra(IntentJniKey.INTENT_KEY_ORG_CHOOSE, chooseType)
        intent.putExtra(IntentJniKey.INTENT_KEY_ORG_ALL_PATH, allPath)
        activity.startActivityForResult(intent, requestCode)
    }

    /**
     * 跳转村架构
     */
    fun startIntentCun(activity: Activity, chooseType: Int, requestCode: Int) {
        val intent = Intent(activity, VillageCunActivity::class.java)
        intent.putExtra(IntentJniKey.INTENT_KEY_ORG_CHOOSE, chooseType)
        activity.startActivityForResult(intent, requestCode)
    }
}